home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 1
/
001.d81
/
french military
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
8KB
|
283 lines
1 dimv(11),h(11):printchr$(142)
5 for a=1to11:readv(a),h(a):next
10 data 6,3,1,11,6,11,11,11
11 data 1,19,6,19,11,19
12 data 1,27,6,27,11,27,6,35
15 z$=""
20 poke53281,6:poke53280,15:print""
50 :
60 :
100 def fnp(x)=2^(x-1)
200 dims(165),r(30,2),l(11,11),w(3),a(165,11)
300 rem french military game, sixth book of mathematical games from scientific
305 rem american by martin gardner
400 rem incorporates match. learning from unexpected hanging by martin gardner
500 rem programmed by g.h. herd sept.78 published in creative computing sept.79
600 print"[147]"
700 print"";
808 print"the french military game"
900 print
1000 print"";
1100 print" by martin gardner"
1200 print:print"<revised by alan gardner for the c-64>"
1250 print"do you need instructions?";:poke198,0:wait198,1:getin$
1260 ifin$="y" or in$="n"then1275
1265 print"please enter y/n":goto700
1275 print"[147]loading data....please wait"
1300 forl=1to9
1400 letl1=fnp(l)
1500 form=l+1to10
1600 letm1=fnp(m)
1700 forr=m+1to11
1880 lets(i)=l1+m1+(fnp(r))
1900 leti=i+1
2000 nextr
2100 nextm
2200 nextl
2300 remprint"[147]"
2305 print""
2310 remnt"do you need instructions";
2315 reminputin$:print"[147]"
2320 ifleft$(in$,1)<>"n"thengosub18100
2400 rem load up learning curve
2500 rem disk command "load data #5,34,a
2600 [129]i[178]1[164]30
2700 [129]j[178]1[164]2
2800 [136]r(i,j)[178]0
2900 [130]j
3000 [130]i
3100 [129]i[178]1[164]11
3200 [129]j[178]1[164]11
3300 [135]l(i,j)
3400 [130]j
3500 [130]i
3600 [143] l(i.j)=0 means move i to j not legal
3700 [143] l(i,j)=1 means move i to j legal black only
3800 [143] l(i,j)=2 means move i to j legal for both
3900 [143]
4000 [136]b[178]6
4100 [136]w(1)[178]1
4200 [136]w(2)[178]2
4300 [136]w(3)[178]4
4400 [136]i0[178]1
4500 [141]11000
4600 [141]15000
4700 [143] main program loop
4800 :
4850 :
4860 :
4870 :
4880 [153]z$;"white pieces are at ";w(1);" ";w(2);" ";w(3)" "
4900 [153]"the black piece is at ";b" "
5000 [153]"your move, from-to x,y cmdcmdcmdcmdcmdcmdcmd";
5100 [133]x,y
5200 [139]x[178]0[175]y[178]0[167]7800
5300 [143] was it a legal move
5400 [141]9100
5500 [139]l2[178]1[167]5800
5600 [153]"foul !!!!! try again."
5700 [137]4800
5800 [143] legal move - what is white position index (s3)
5900 [153]"":p$[178]" cmdcmd "
5905 [145]x[141]17000,17100,17200,17300,17400,17500,17600,17700,17800,17900,18000
6000 [153]"":p$[178]" cmdcmd wait"
6005 [145]y[141]17000,17100,17200,17300,17400,17500,17600,17700,17800,17900,18000
6100 [141]11000
6200 [139]i0[179][178]19[167]6600
6300 [153]"that's 20 moves, ace, and you haven't trapped me."
6400 [137]7800
6500 [143] what is black's best move - if any
6600 [141]11600
6700 [139]m4[178]0[167]8100
6800 [143] computer moves
6900 [153]z$;:[153]" ":[153]z$"oni move to ";m4
7000 [153]"":p$[178]" cmdcmd "
7005 [145]b[141]17000,17100,17200,17300,17400,17500,17600,17700,17800,17900,18000
7100 [153]"":p$[178]"stop cmdcmd wait"
7105 [145]m4[141]17000,17100,17200,17300,17400,17500,17600,17700,17800,17900,18000
7150 [153]z$
7200 [136]r(i0,1)[178]s3
7308 [136]r(i0,2)[178]m4
7400 [136]b[178]m4
7500 [136]i0[178]i0[170]1
7608 [139]b[179][177]1[167]4700
7700 [143] here only if machine wins
7800 [153]z$"i win......"
7900 [136]w[178]1
8000 [137]8300
8100 [153]z$"i lost......"
8200 [136]w[178][171]1
8300 [143] update array a
8400 [141]13000
8500 [153]"want to play again";
8600 [133]e$
8700 [139][200](e$,1)[178]"y"[167]4000
8800 [139][200](e$,1)[178]"n"[167]9000
8900 [153]"please answer y or n":[153]:[137]8500
9000 [143] ***** text *****
9005 [151]198,0
9010 [153]"load"
9015 [153]""
9020 [153]"";
9025 [153]"* * * the end * * *"
9030 [153]""
9035 [137] 63000
9100 [143] check whites move for legalivy
9200 [136]l2[178][171]1
9308 [129]i2[178]1[164]3
9400 [136]j2[178]i2
9500 [139]w(i2)[178]x[167]9900
9600 [130]i2
9700 [143] no white piece at x
9800 [137]10900
9900 [143] if black is at y then illegal
10000 [139]b[178]y[167]10900
10100 [143] illegal if white at y
10200 [129]i2[178]1[164]3
10300 [139]w(i2)[178]y[167]10900
10400 [130]i2
10500 [139]l(x,y)[179][177]2[167]10900
10600 [143] legal move for white
10700 [136]w(j2)[178]y
10800 [136]l2[178]1
10900 [142]
11000 [143] calculate new white position number
11100 [136]a3[178][165]p(w(1))[170][165]p(w(2))[170][165]p(w(3))
11200 [129]s3[178]1[164]165
11300 [139]s(s3)[178]a3[167]11500
11400 [130]s3
11500 [142]
11600 [143] pick black's best move
11700 [136]m4[178]0
11800 [129]i4[178]1[164]11
11900 [139]l(b,i4)[178]0[167]12800
12000 [143] occupied by white?
12100 [129]j4[178]1[164]3
12200 [139]w(j4)[178]i4[167]12800
12300 [130]j4
12400 [139]m4[178]0[167]12700
12500 [139]a(s3,m4)[177][178]a(s3,i4)[167]12800
12600 [143] new best move
12700 [136]m4[178]i4
12800 [130]i4
12900 [142]
13000 [143] update at game end
13100 [129]i6[178]1[164]i0[171]1
13200 [136]s[178]r(i6,1)
13300 [136]m[178]r(i6,2)
13400 [136]a(s,m)[178]a(s,m)[170]w
13500 [130]i6
13600 [142]
13700 [143] data for l array
13800 [131] 0,2,2,2,0,0,0,0,0,0,0
13900 [131] 1,0,2,0,2,2,0,0,0,0,0
14000 [131] 1,2,0,2,0,2,0,0,0,0,0
14100 [131] 1,0,2,0,0,2,2,0,0,0,0
14200 [131] 0,1,0,0,0,2,0,2,0,0,0
14300 [131] 0,1,1,1,2,0,2,2,2,2,0
14400 [131] 0,0,0,1,0,2,0,0,0,2,0
14500 [131] 0,0,0,0,1,1,0,0,2,0,2
14600 [131] 0,0,0,0,0,1,0,2,0,2,2
14700 [131] 0,0,0,0,0,1,1,0,2,0,2
14800 [131] 0,0,0,0,0,0,0,2,2,2,0
15000 [143] draw board
15100 [153]"load"
15225 [153]" print2spc(spc(spc( print5spc(spc(spc( print8spc(spc(spc(
15250 print" [166] [166][164][164][164][164][166] [166][164][164][164][164][166] [166]
15300 [153]" spc( spc( spc( spc( spc( spc(
15400 print" [206][166][166][166][166][205] [166][166][166][166] [206][166][166][166][166][205]
15500 [153]" (NULL) then (NULL) then (NULL) then (NULL)
15600 print" [153]1[166][166][166] [206] [153]3[166][166][166] [205] [153]6[166][166][166] [206] [153]9[166][166][166] [205] [153]11[166][166]
15700 [153]" spc( spc((NULL)tototospc( spc(tototo(NULL)spc( spc((NULL)tototospc( spc(tototo(NULL)spc( spc(
15800 print" [166] [166][205] [166] [166] [206][166] [166][205] [166] [166] [206][166] [166]
15900 [153]" spc(spc(spc(spc( (NULL) spc(spc(spc(spc( (NULL) spc(spc(spc(spc( (NULL) spc(spc(spc(spc( (NULL) spc(spc(spc(spc(
16000 print" [205] [167] [206] [167] [205] [167] [206]
16100 [153]" (NULL)print4spc(spc(spc((NULL) print7spc(spc(spc( (NULL)print10spc(spc((NULL)
16200 print" [166] [166][164][164][164][164][166] [166][164][164][164][164][166] [166]
16300 [153]" spc( spc( spc( spc( spc( spc(
16400 print" [166][166][166][166] [166][166][166][166] [166][166][166][166]
16500 p$[178]" cmdcmd ":[153]"":[141]17000:[153]"":[141]17100:[153]"":[141]17300
16600 p$[178]"stop cmdcmd ":[153]"":[141]17500
16800 [142]
16900 [143] square 1
17000 [129]v[178]1[164]v(1):[153]"";:[130]:[129]h[178]1[164]h(1):[153]"";:[130]:[153]p$:[142]
17100 [129]v[178]1[164]v(2):[153]"";:[130]:[129]h[178]1[164]h(2):[153]"";:[130]:[153]p$:[142]
17200 [129]v[178]1[164]v(3):[153]"";:[130]:[129]h[178]1[164]h(3):[153]"";:[130]:[153]p$:[142]
17300 [129]v[178]1[164]v(4):[153]"";:[130]:[129]h[178]1[164]h(4):[153]"";:[130]:[153]p$:[142]
17400 [129]v[178]1[164]v(5):[153]"";:[130]:[129]h[178]1[164]h(5):[153]"";:[130]:[153]p$:[142]
17500 [129]v[178]1[164]v(6):[153]"";:[130]:[129]h[178]1[164]h(6):[153]"";:[130]:[153]p$:[142]
17600 [129]v[178]1[164]v(7):[153]"";:[130]:[129]h[178]1[164]h(7):[153]"";:[130]:[153]p$:[142]
17700 [129]v[178]1[164]v(8):[153]"";:[130]:[129]h[178]1[164]h(8):[153]"";:[130]:[153]p$:[142]
17800 [129]v[178]1[164]v(9):[153]"";:[130]:[129]h[178]1[164]h(9):[153]"";:[130]:[153]p$:[142]
17900 [129]v[178]1[164]v(10):[153]"";:[130]:[129]h[178]1[164]h(10):[153]"";:[130]:[153]p$:[142]
18000 [129]v[178]1[164]v(11):[153]"";:[130]:[129]h[178]1[164]h(11):[153]"